VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsReg"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
 Option Explicit
Private Const objreg_SZ = (1)
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const KEY_ALL_ACCESS = &H3F
Private Const ERROR_SUCCESS = 0&
Private Const objreg_OPTION_NON_VOLATILE = 0&


Private mstrLastDocClassCode As String
Private mstrInputImageFolder As String
Public Function ClearDbRegForDev() As Boolean

    SaveSettingC "Software\Mindkey Software Solutions\KTInterface", "AdoConnectString", "", objreg_SZ

End Function
Public Property Let FormX(ByVal vdata As String)
   'sets the system in the registry
    SaveSettingC "Software\Mindkey Software Solutions\KTInterface", "Form X", vdata, objreg_SZ
End Property

Public Property Get FormX() As String
    'gets the system from the registry
    
    'SET FORM IN MIDDLE OF SCREEN IF NO objreg SETTINGS
    If GetSettingC("Software\Mindkey Software Solutions\KTInterface", "Form X") = "" Then
        FormX = (Screen.Height / 2) - (4152 / 2) ' 4152 is the form height
    Else
        FormX = GetSettingC("Software\Mindkey Software Solutions\KTInterface", "Form X")
    End If
    
End Property

Public Property Let FormY(ByVal vdata As String)
'sets the tiff path in the registry
    SaveSettingC "Software\Mindkey Software Solutions\KTInterface", "Form Y", vdata, objreg_SZ
End Property

Public Property Get FormY() As String
'gets the tiffpath from the registry
    
    'SET FORM IN MIDDLE OF SCREEN IF NO objreg SETTINGS
    If GetSettingC("Software\Mindkey Software Solutions\KTInterface", "Form Y") = "" Then
        FormY = (Screen.Width / 2) - (6948 / 2) '6948 is the form width
    Else
        FormY = GetSettingC("Software\Mindkey Software Solutions\KTInterface", "Form Y")
    End If
    
End Property

Public Property Let LastEmailDttm(ByVal vdata As Date)
    SaveSettingC "Software\Mindkey Software Solutions\KTInterface", "LastEmailDttm", vdata, objreg_SZ
End Property

Public Property Get LastEmailDttm() As Date
    LastEmailDttm = IIf(GetSettingC("Software\Mindkey Software Solutions\KTInterface", "LastEmailDttm") = "", (Now - 1 / 24), GetSettingC("Software\Mindkey Software Solutions\KTInterface", "LastEmailDttm"))
End Property
Public Property Let LastRunDttm(ByVal vdata As String)
    SaveSettingC "Software\Mindkey Software Solutions\KTInterface", "LastRunDttm", vdata, objreg_SZ
End Property

Public Property Get LastRunDttm() As String
    LastRunDttm = IIf(GetSettingC("Software\Mindkey Software Solutions\KTInterface", "LastRunDttm") = "", Now, GetSettingC("Software\Mindkey Software Solutions\KTInterface", "LastRunDttm"))
End Property
Public Property Get GetDayStart(ByVal Day As String) As String
    GetDayStart = IIf(GetSettingC("Software\Mindkey Software Solutions\Image\Uptime\" & Day, "Start") = "", "0000", GetSettingC("Software\Mindkey Software Solutions\Image\Uptime\" & Day, "Start"))
End Property

Public Property Let SetDayStart(ByVal Day As String, vdata As String)
    'GetDayStart = IIf(GetSettingC("Software\Mindkey Software Solutions\Image\Uptime\" & Day, "Start") = "", "0000", GetSettingC("Software\Mindkey Software Solutions\Image\Uptime\" & Day, "Start"))
    SaveSettingC "Software\Mindkey Software Solutions\Image\Uptime\" & Day, "Start", vdata, objreg_SZ
End Property

Public Property Get GetDayEnd(ByVal Day As String) As String
    GetDayEnd = IIf(GetSettingC("Software\Mindkey Software Solutions\Image\Uptime\" & Day, "End") = "", "0000", GetSettingC("Software\Mindkey Software Solutions\Image\Uptime\" & Day, "End"))
End Property

Public Property Let SetDayEnd(ByVal Day As String, vdata As String)
    'GetDayStart = IIf(GetSettingC("Software\Mindkey Software Solutions\Image\Uptime\" & Day, "Start") = "", "0000", GetSettingC("Software\Mindkey Software Solutions\Image\Uptime\" & Day, "Start"))
    SaveSettingC "Software\Mindkey Software Solutions\Image\Uptime\" & Day, "End", vdata, objreg_SZ
End Property

Public Property Get GetEMailAddress(ByVal Num As String) As String
    GetEMailAddress = IIf(GetSettingC("Software\Mindkey Software Solutions\Image\EMail", Num) = "", "", GetSettingC("Software\Mindkey Software Solutions\Image\EMail", Num))
End Property

Public Property Let SetEMailAddress(ByVal Num As String, vdata As String)
    'GetEMailAddress = IIf(GetSettingC("Software\Mindkey Software Solutions\Image\EMail", Num) = "", "", GetSettingC("Software\Mindkey Software Solutions\Image\EMail", Num))
    SaveSettingC "Software\Mindkey Software Solutions\Image\EMail", Num, vdata, objreg_SZ
End Property


Public Property Let LogFileSeq(ByVal vdata As Long)
    SaveSettingC "Software\Mindkey Software Solutions\KTInterface", "LogFileSeq", vdata, objreg_SZ
End Property

Public Property Get LogFileSeq() As Long
    LogFileSeq = IIf(GetSettingC("Software\Mindkey Software Solutions\KTInterface", "LogFileSeq") = "", 0, GetSettingC("Software\Mindkey Software Solutions\KTInterface", "LogFileSeq"))
End Property

Public Property Let PolTimeInterval(ByVal vdata As Long)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.FilenetTextPath = 5
    SaveSettingC "Software\Mindkey Software Solutions\KTInterface", "PolTimeInterval", vdata, objreg_SZ
End Property

Public Property Get PolTimeInterval() As Long
'used when retrieving value of a property, on the right side of an assignment.
    PolTimeInterval = IIf(GetSettingC("Software\Mindkey Software Solutions\KTInterface", "PolTimeInterval") = "", 0, GetSettingC("Software\Mindkey Software Solutions\KTInterface", "PolTimeInterval"))
End Property
Public Property Let LogFilePath(ByVal vdata As String)
    SaveSettingC "Software\Mindkey Software Solutions\KTInterface", "LogFilePath", vdata, objreg_SZ
End Property

Public Property Get LogFilePath() As String
    LogFilePath = IIf(GetSettingC("Software\Mindkey Software Solutions\KTInterface", "LogFilePath") = "", "", GetSettingC("Software\Mindkey Software Solutions\KTInterface", "LogFilePath"))
End Property

Public Property Let Settings(ByVal vdata As String)
    SaveSettingC "Software\Mindkey Software Solutions\KTInterface", "Settings", vdata, objreg_SZ
End Property

Public Property Get Settings() As String
    Settings = IIf(GetSettingC("Software\Mindkey Software Solutions\KTInterface", "Settings") = "", "Development", GetSettingC("Software\Mindkey Software Solutions\KTInterface", "Settings"))
End Property

Public Property Let LastUser(strSetting As String, ByVal vdata As String)
    SaveSettingC "Software\Mindkey Software Solutions\KTInterface\" & strSetting, "UserName", vdata, objreg_SZ
End Property
Public Property Get LastUser(strSetting As String) As String
    LastUser = IIf(GetSettingC("Software\Mindkey Software Solutions\KTInterface\" & strSetting, "UserName") = "", "", GetSettingC("Software\Mindkey Software Solutions\KTInterface\" & strSetting, "UserName"))
End Property

Public Property Let Password(strSetting As String, ByVal vdata As String)
    SaveSettingC "Software\Mindkey Software Solutions\KTInterface\" & strSetting, "Password", vdata, objreg_SZ
End Property

Public Property Get Password(strSetting As String) As String
    Password = IIf(GetSettingC("Software\Mindkey Software Solutions\KTInterface\" & strSetting, "Password") = "", "", GetSettingC("Software\Mindkey Software Solutions\KTInterface\" & strSetting, "Password"))
End Property

Public Property Let LogErrors(ByVal vdata As Integer)
    SaveSettingC "Software\Mindkey Software Solutions\KTInterface", "LogErrors", vdata, objreg_SZ
End Property

Public Property Get LogErrors() As Integer
    LogErrors = IIf(GetSettingC("Software\Mindkey Software Solutions\KTInterface", "LogErrors") = "", 0, GetSettingC("Software\Mindkey Software Solutions\KTInterface", "LogErrors"))
End Property


Private Function GetSettingC(strKeyName As String, strValueName As String) As String
'Purpose
'*******
'Gets the value a certain registry key

On Error GoTo GetSettingsCFix

'Variables
'*********
    Dim lngRetVal As Long           'Result of the API functions
    Dim hKey As Long                'Handle of the opened key
    Dim szBuffer As String          'Setting of the queried value
    Dim lngBuffSize As Long
    
'Code
'****
    'Create the buffer
    szBuffer = Space(500)
    lngBuffSize = 500
    
    'Open the specified registry key
    lngRetVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE, strKeyName, 0, KEY_ALL_ACCESS, hKey)
    If lngRetVal <> ERROR_SUCCESS Then
        Exit Function
    End If
    
    'Read the opened registry key
    lngRetVal = RegQueryValueEx(hKey, strValueName, 0, 0, szBuffer, lngBuffSize)
    
    GetSettingC = Trim(Left(szBuffer, lngBuffSize - 1))
    
    'Close the registry key
    RegCloseKey (hKey)

    Exit Function
    
GetSettingsCFix:
    'HandleError Err.Description, "clsReg.GetSettingsC: "
    
End Function

Private Sub SaveSettingC(strKeyName As String, strValueName As String, varValueSetting As Variant, lngValueType As Long)
'Purpose
'*******
'Set the value of a Registry key if it exist.
'if the registry key doesn't exist it will be created

On Error GoTo SaveSettingsCFix

'Variables
'*********
    Dim hKey As Long            'Handle to the key
    Dim lngRetVal As Long       'Result of API functions
    Dim SA As TSECURITY_ATTRIBUTES
    Dim create As Long

'Code
'****
    'Open or Ceate the registry key
    lngRetVal = RegCreateKeyEx(HKEY_LOCAL_MACHINE, strKeyName, 0, "", objreg_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, SA, hKey, create)
    If lngRetVal <> ERROR_SUCCESS Then
        MsgBox "An error occurred while trying to set the registry key", vbCritical
        Exit Sub
    End If
        
    'Set or create a registry value
    lngRetVal = RegSetValueEx(hKey, strValueName, 0, lngValueType, varValueSetting, CDec(Len(varValueSetting) + 1))
        
    RegCloseKey (hKey)
    
    Exit Sub
    
SaveSettingsCFix:
    'HandleError Err.Description, "clsReg.SavesSettingsC: "
    
End Sub
Public Sub DeleteKey(strKeyName As String)
'RegDeleteKey (ByVal hKey As Long, ByVal lpSubKey As String) As Long

    Dim lngRetVal As Long       'Result of API functions

    On Error GoTo DeleteKeyFix

    lngRetVal = RegDeleteKey(HKEY_LOCAL_MACHINE, strKeyName)
    If lngRetVal <> ERROR_SUCCESS Then
        MsgBox "An error occurred while trying to set the registry key", vbCritical
        Exit Sub
    End If

    Exit Sub
    
DeleteKeyFix:
    'HandleError Err.Description, "clsReg.DeleteKey: "
End Sub
Public Property Let DebugMode(ByVal vdata As String)
    SaveSettingC "Software\Mindkey Software Solutions\KTInterface", "DebugMode", vdata, objreg_SZ
End Property

Public Property Get DebugMode() As String
    DebugMode = IIf(GetSettingC("Software\Mindkey Software Solutions\KTInterface", "DebugMode") = "", 0, GetSettingC("Software\Mindkey Software Solutions\KTInterface", "DebugMode"))
End Property

Public Property Let DTDLocation(ByVal vdata As String)
    SaveSettingC "Software\Mindkey Software Solutions\KTInterface", "DTDLocation", vdata, objreg_SZ
End Property

Public Property Get DTDLocation() As String
    DTDLocation = IIf(GetSettingC("Software\Mindkey Software Solutions\KTInterface", "DTDLocation") = "", 0, GetSettingC("Software\Mindkey Software Solutions\KTInterface", "DTDLocation"))
End Property
